<template>
  <v-container class="box">
    <v-dialog v-model="dialog" width="500">
      <template v-slot:activator="{ on, attrs }">
        <v-btn v-bind="attrs" v-on="on">
          点击获取激活码
        </v-btn>
      </template>

      <v-card>
        <v-card-title>
          IDEA 激活码
        </v-card-title>

        <v-textarea
          id="idea-code"
          value="UD5T6WF5YW-eyJsaWNlbnNlSWQiOiJVRDVUNldGNVlXIiwibGljZW5zZWVOYW1lIjoi5rC45LmF5YWN6LS577yaIGxvb2tkaXbCt2NvbSIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiIiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IkRDIiwicGFpZFVwVG8iOiIyMDIxLTAxLTIwIiwiZXh0ZW5kZWQiOmZhbHNlfSx7ImNvZGUiOiJJSSIsInBhaWRVcFRvIjoiMjAyMS0wMS0yMCIsImV4dGVuZGVkIjpmYWxzZX0seyJjb2RlIjoiREIiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMjAiLCJleHRlbmRlZCI6ZmFsc2V9LHsiY29kZSI6IlJNIiwicGFpZFVwVG8iOiIyMDIxLTAxLTIwIiwiZXh0ZW5kZWQiOmZhbHNlfSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAyMS0wMS0yMCIsImV4dGVuZGVkIjpmYWxzZX0seyJjb2RlIjoiUlNWIiwicGFpZFVwVG8iOiIyMDIxLTAxLTIwIiwiZXh0ZW5kZWQiOnRydWV9LHsiY29kZSI6IlJTVSIsInBhaWRVcFRvIjoiMjAyMS0wMS0yMCIsImV4dGVuZGVkIjpmYWxzZX0seyJjb2RlIjoiUEMiLCJwYWlkVXBUbyI6IjIwMjEtMDEtMjAiLCJleHRlbmRlZCI6ZmFsc2V9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDIxLTAxLTIwIiwiZXh0ZW5kZWQiOmZhb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bn1dqfBw1BuTE29V2FJKicJSu8iEOpfoafwJISXmz1wnnWL3V/0NxTulfWsXugOoLfv0ZIBP1xH9kmf22jjQ2JiHhQZP7ZDsreRrOeIQ/c4yR8IQvMLfC0WKQqrHu5ZzXTH4NO3CwGWSlTY74kE91zXB5mwWAx1jig+UXYc2w4RkVhy0//lOmVya/PEepuuTTI4+UJwC7qbVlh5zfhj8oTNUXgN0AOc+Q0/WFPl1aw5VV/VrO8FCoB15lFVlpKaQ1Yh+DVU8ke+rt9Th0BCHXe0uZOEmH0nOnH/0onD"
        >
        </v-textarea>

        <v-divider></v-divider>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="primary" text @click="handleClickCopy">
            复制
          </v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
  </v-container>
</template>

<script>
export default {
  data() {
    return {
      dialog: false
    };
  },
  created() {
    const { key } = this.$route.query;
    if (key !== "a86621507078fb5c10d7de28ffc86e0a") {
      this.$router.push("/");
    }
  },
  methods: {
    handleClickCopy() {
      const doc = document.querySelector("#idea-code");
      doc.select();
      document.execCommand("Copy");
      this.dialog = false;
      alert("复制成功, 进入 idea 粘贴到Activation code");
    }
  }
};
</script>

<style>
.box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 500px;
  height: 800px;
}
</style>
